<template>
  <el-dialog append-to-body title="修改结案状态" :visible="visible" @close="handleClose" width="40%">
    <el-form ref="form" :model="formData" :rules="rules" class="white-card" label-width="110px">
      <el-form-item label="结案状态：" prop="finishStatus">
        <el-select v-model="formData.finishStatus" placeholder="请选择">
          <el-option v-for="item in dictList" :key="item.id" :label="item.name" :value="item.name"></el-option>
        </el-select>
      </el-form-item>
    </el-form>
    <div class="split"></div>

    <div class="dialog-footer-btn">
      <el-button @click="handleClose" type="primary" plain>关闭</el-button>
      <el-button type="primary" @click="handleGiveUp" :loading="submitting">确 定</el-button>
    </div>
  </el-dialog>
</template>
<script>
import * as mixins from "@/utils/mixins";
import * as workOrderApi from "@/api/workOrder/index";
import * as dictApi from "@/api/dict";

export default {
  name: "AbandonComplaint",
  mixins: [mixins.loading, mixins.form, mixins.dialog],
  props: ["visible", "workOrderNo", "finishStatus"],
  components: {},
  data() {
    return {
      formData: {
        finishStatus: "",
      },
      rules: {
        finishStatus: [{ required: true, message: "请选择" }],
      },
      submitting: false,
      dictList: [],
    };
  },
  computed: {},
  watch: {},
  created() {},
  mounted() {},
  methods: {
    show() {
      this.formData.finishStatus = this.finishStatus;
      this.getDictList();
    },
    getDictList() {
      dictApi
        .list({ parentCode: "1009" })
        .then((res) => {
          this.dictList = res.result;
        })
        .finally(() => {});
    },
    handleGiveUp() {
      this.validateAndConfirm("form")
        .then((res) => {
          this.submitting = true;
          return workOrderApi.distribute.modifyFinishStatus({
            workOrderNo: this.workOrderNo,
            finishStatus: this.formData.finishStatus,
          });
        })
        .then((r) => {
          this.$message.success(r.msg);
          this.$emit("success");
          this.handleClose();
        })
        .finally(() => {
          this.submitting = false;
        });
    },
  },
};
</script>
<style lang="less" scoped>
.el-select {
  width: 100%;
}
</style>
